package controller;

import java.util.Calendar;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class TestDate {
	static Calendar calendar = Calendar.getInstance();//返回的是基于默认时区的当前时间
	static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
	static Date BorrowDate = new Date(System.currentTimeMillis());
	static LocalDateTime now = LocalDateTime.now();
	public TestDate() {
 
	}	

	public static Date getNowTime(){
		String b = formatter.format(BorrowDate);
		return java.sql.Date.valueOf(b);
	}

	public static Date getAfterTime(Date x){
		if(x==null) {
			calendar.setTime(BorrowDate);
			calendar.add(Calendar.MONTH, 3);// 这里就是月份的相加
		}
		//续借操作
		else {
			calendar.setTime(x);
			calendar.add(Calendar.MONTH, 1);// 这里就是月份的相加
		}
		java.util.Date returnDate = calendar.getTime();// 获取到相加后的时间
		String r = formatter.format(returnDate);
		return java.sql.Date.valueOf(r);
	}
}